package model.logic.operand;


/**
 * <tt>Variable</tt> is an <tt>Operand</tt> of a <tt>Proposition</tt> having a specific name. <br>
 * Two variables are equal if their names are equal.
 
 * @author Marius Tempelmeier, Martin Seils, Timo Kaiser 
 *
 */
public class Variable implements Operand {
	
	/**
	 * identifier for this. 
	 */
	private final String name;

	public Variable(String name) {
		this.name = name;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		return obj instanceof Variable ? ((Variable) obj).equals(this) : false;
	}
	
	/**
	 * Two <tt>Variable</tt> objects are equal, if their <tt>name</tt>s are equal.  
	 * @param obj Variable to be checked 
	 * @return true <=> this.name =e obj.name
	 */
	public boolean equals(Variable obj) {
		return this.getName().equals(obj.getName());
	}

	public String getName() {
		return this.name;
	}
}
